﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamFluentAPI.Infrastructure.Base;

namespace SteamFluentAPI.Infrastructure
{
    public class SteamApps : SteamInterface
    {
        /// <summary>
        /// Full list of every publicly facing program in the store/library.
        /// </summary>
        [SteamMethod("v2")]
        public GetAppList GetAppList { get { return new GetAppList(); } }
        /// <summary>
        /// (NOT IMPLEMENTED)
        /// </summary>
        [NotImplemented]
        public GetServersAtAddress GetServersAtAddress { get { return new GetServersAtAddress(); } }
        /// <summary>
        /// Check if a given app version is the most current available.
        /// </summary>
        [SteamMethod("v1")]
        public UpToDateCheck UpToDateCheck { get { return new UpToDateCheck(); } }
    }

    #region Parameters

    public class GetAppList : SteamMethod
    {
        private GetAppListEntity _root;

        public GetAppListEntity Root
        {
            get
            {
                if (_root == null)
                {
                    _root = new GetAppListEntity();
                }
                return _root;
            }
        }
        
    }

    public class GetServersAtAddress : SteamMethod
    {
        
    }

    public class UpToDateCheck : SteamAppMethod
    {
        /// <summary>
        /// The installed version of the game. (REQUIRED)
        /// </summary>
        /// <param name="version"></param>
        [RequiredParameter("version")]
        public void Version(int version)
        {
            Add("version", version);
        }
    }

    #endregion

    #region Entites

    public class App
    {
        [JsonProperty(PropertyName = "appid")]
        public int AppID { get; set; }

        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }
    }

    public class Applist
    {
        [JsonProperty(PropertyName = "apps")]
        public IEnumerable<App> Apps { get; set; }
    }

    public class GetAppListEntity : SteamEntity
    {
        [JsonProperty(PropertyName = "applist")]
        public Applist AppList { get; set; }
    }

    #endregion
}
